package models

import "gorm.io/gorm"

type Goods struct {
	gorm.Model
	GoodsTitle string  `gorm:"type:varchar(50)"`
	GoodsDesc  string  `gorm:"type:varchar(50)"`
	GoodsPrice float64 `gorm:"type:decimal(10,2)"`
	GoodsType  string  `gorm:"type:varchar(50)"`
	GoodsStock int     `gorm:"type:int"`
	Status     int     `gorm:"type:int;default:1;comment:商品状态: 1 已上架 0 已下架"`
}

func (g *Goods) Create() error {
	return DB.Create(&g).Error
}
func (g *Goods) Detail() error {
	return DB.Where(" status = 1").First(&g).Error
}
